<?php echo $this->fetch('header.html'); ?>
<script>
    var cate_height;
    var scroll_lock=false;
    $(function(){
        cate_height=$(".categories-container").eq(0).height()+16;
        $(window).bind("scroll",function(){
            if(!scroll_lock){
            var sTop = $(window).scrollTop();
            var max_index=$(".category-items .col:eq(0) .category-item:eq(0)").attr('data-id');
            $(".category-items .col:eq(0) .category-item").each(function(){
                if((($(this).offset().top)-cate_height)<=sTop){
                    max_index=$(this).attr('data-id');
                    
                }
            });
            $(".categories-container .ui-category-item").removeClass('selected');
            $("#cate_item_"+max_index).addClass('selected');
        }
        })
    })
    function scroll_cate(id){
        scroll_lock=true;
        $('html,body').animate({scrollTop: (($('#cate_'+id).offset().top)-cate_height)},function(){
            var time=setInterval(function(){
                scroll_lock=false;
                clearInterval(time);
            },50);
             
        });
        
        $(".categories-container .ui-category-item").removeClass('selected');
            $("#cate_item_"+id).addClass('selected');
            
    }
</script>
<div id="main" class="w-full">
<div id="page-category" class="w mt10">
	<div class="w" area="top" data-position="1" widget_type="area">
		<?php $this->display_widgets(array('page'=>'gcategory','area'=>'top')); ?>
	</div>
    <div class="search-type mb20 clearfix">
			<div class="float-right btn-type">
				<a href="<?php echo url('app=category'); ?>" class="current">全部商品分类</a>
				<a href="<?php echo url('app=category&act=store'); ?>">全部店铺分类</a>
                                <a href="<?php echo url('app=brand'); ?>">全部品牌</a>
			</div>                       
		</div>
	<div class="gcategory left float-left">
            <div class="categories">
                <div class="categories-container clearfix">
		<?php $_from = $this->_var['gcategorys']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }; $this->push_vars('', 'gcategory');$this->_foreach['fe_gc'] = array('total' => count($_from), 'iteration' => 0);
if ($this->_foreach['fe_gc']['total'] > 0):
    foreach ($_from AS $this->_var['gcategory']):
        $this->_foreach['fe_gc']['iteration']++;
?>
                <a class="ui-category-item <?php if (($this->_foreach['fe_gc']['iteration'] <= 1)): ?>selected<?php endif; ?>" href="javascript:void(0)" onclick="scroll_cate(<?php echo $this->_var['gcategory']['id']; ?>)" id="cate_item_<?php echo $this->_var['gcategory']['id']; ?>"><?php echo htmlspecialchars($this->_var['gcategory']['value']); ?></a>
		<?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
                <div style="clear:both;height:0; display:block; overflow:hidden"></div>
                </div>
                </div>
                <div class="category-items clearfix">
                    <div class="col float-left">
		<?php $_from = $this->_var['gcategorys']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }; $this->push_vars('', 'gcategory');$this->_foreach['fe_gc'] = array('total' => count($_from), 'iteration' => 0);
if ($this->_foreach['fe_gc']['total'] > 0):
    foreach ($_from AS $this->_var['gcategory']):
        $this->_foreach['fe_gc']['iteration']++;
?>
                        <div class="category-item m" id="cate_<?php echo $this->_var['gcategory']['id']; ?>" data-id="<?php echo $this->_var['gcategory']['id']; ?>">
			<div class="mt">
                            <h2 class="item-title">
                                <b></b>
                                <i></i><a href="<?php echo url('app=search&cate_id=' . $this->_var['gcategory']['id']. ''); ?>"><span><?php echo htmlspecialchars($this->_var['gcategory']['value']); ?></span></a>
                            </h2>
			<div class="mc">
                            <?php if ($this->_var['gcategory']['cate_goods']): ?>
                            <div class="item-hot clearfix">
                                <?php $_from = $this->_var['gcategory']['cate_goods']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }; $this->push_vars('', 'goods');if (count($_from)):
    foreach ($_from AS $this->_var['goods']):
?>
                                <a href="index.php?app=goods&id=<?php echo $this->_var['goods']['goods_id']; ?>" target="_blank"><img src="<?php echo $this->_var['goods']['default_image']; ?>" width="130" height="130" ></a>
                                <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
                            </div>
                            <div class="item-info">热卖爆品</div>
                            <?php endif; ?>
                            <div class="items">
				<?php $_from = $this->_var['gcategory']['children']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }; $this->push_vars('', 'child');if (count($_from)):
    foreach ($_from AS $this->_var['child']):
?>
                                <dl class="clearfix">
				<dt><a href="<?php echo url('app=search&cate_id=' . $this->_var['child']['id']. ''); ?>"><?php echo htmlspecialchars($this->_var['child']['value']); ?></a></dt>
                                <dd>
                                    <?php $_from = $this->_var['child']['children']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }; $this->push_vars('', 'child2');if (count($_from)):
    foreach ($_from AS $this->_var['child2']):
?>
                                    <a href="<?php echo url('app=search&cate_id=' . $this->_var['child2']['id']. ''); ?>"><?php echo htmlspecialchars($this->_var['child2']['value']); ?></a>
                                    <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
                                </dd>
                                <div style="clear:both;height:0; display:block; overflow:hidden"></div>
                                </dl>
				<?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
                                </div>
			</div>
                        </div>
                            </div>
                        <?php if ($this->_var['half_count'] == $this->_foreach['fe_gc']['iteration']): ?>
                        </div>
                
                        <div class="col float-left" style="margin-right: 0">
                        <?php endif; ?>
		
		<?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
                </div>
                <div style="clear:both;height:0; display:block; overflow:hidden"></div>
                </div>
	</div>
    <div class="right float-right">
        <div class="hot-items m">
        <h2 class="item-bar mt"><i></i> <span>热销榜</span></h2>
        <div class="mc">
        <?php $_from = $this->_var['cate_hot_goods']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }; $this->push_vars('', 'goods');if (count($_from)):
    foreach ($_from AS $this->_var['goods']):
?>
        <div class="hot-item">
            <div class="p-img">
                <a href="index.php?app=goods&id=<?php echo $this->_var['goods']['goods_id']; ?>" target="_blank"><img src="<?php echo $this->_var['goods']['default_image']; ?>" width="220" height="220" alt=""></a>
            </div>
            <div class="p-info">
                <a class="p-title" href="index.php?app=goods&id=<?php echo $this->_var['goods']['goods_id']; ?>"><?php echo htmlspecialchars($this->_var['goods']['goods_name']); ?></a>
                <span class="p-price"><em><?php echo price_format($this->_var['goods']['price']); ?></em></span>
            </div>
        </div>
        <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
        </div>
        </div>
    </div>
    <div style="clear:both;height:0; display:block; overflow:hidden"></div>
</div>
</div>
<script src="<?php echo $this->res_base . "/" . 'js/posfixed.js'; ?>"></script>
<script>
    
                                //导航那个悬浮
                                $(".categories-container").posfixed({
                                    distance: 0,
                                    pos: "top",
                                    type: "while",
                                    hide: false
                                });
</script>
<?php echo $this->fetch('server.html'); ?>
<?php echo $this->fetch('footer.html'); ?>